package pack1;

import java.util.Iterator;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class sprg29 {
public static void main(String[] args) throws InterruptedException {
	
	WebDriver driver=new FirefoxDriver();
	
	driver.get("https://demo.vtiger.com");
	driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
	
	driver.findElement(By.id("submitButton")).click();
	Thread.sleep(1000);
	driver.findElement(By.linkText("Read License")).click();

	Iterator<String> allWH = driver.getWindowHandles().iterator();
String ss=allWH.next();
String s=allWH.next();
	
	driver.switchTo().window(s);
	Thread.sleep(1000);
	driver.findElement(By.xpath("//a[text()='Copyrights ']")).click();
	
	
	Iterator<String> allWH1 = driver.getWindowHandles().iterator();
	String s1=allWH1.next();
	s1=allWH1.next();
	s1=allWH1.next();
			
		driver.switchTo().window(s1);
		Thread.sleep(1000);
		driver.close();
		Thread.sleep(1000);
		driver.switchTo().window(s);
		driver.close();
		Thread.sleep(1000);
		driver.switchTo().window(ss);
		driver.close();

	
	driver.close();
}
}
